package com.emm.yixun.system.service.impl.app;

import java.io.UnsupportedEncodingException;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.jws.WebService;

import com.emm.yixun.common.response.Response;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.emm.yixun.basic.mapper.NoticeMapper;
import com.emm.yixun.basic.mapper.UserTokenMapper;
import com.emm.yixun.basic.mapper.VersionMapper;
import com.emm.yixun.basic.service.AppPushService;
import com.emm.yixun.basic.service.AreaService;
import com.emm.yixun.basic.service.BaseCodeTypeService;
import com.emm.yixun.basic.service.BaseCodeValueService;
import com.emm.yixun.basic.service.BusinessRelationService;
import com.emm.yixun.basic.service.ImageService;
import com.emm.yixun.basic.service.MerchantResourcesService;
import com.emm.yixun.basic.service.MerchantService;
import com.emm.yixun.basic.service.NoticeService;
import com.emm.yixun.basic.service.PriceRecordService;
import com.emm.yixun.basic.service.ProblemFeedbackService;
import com.emm.yixun.basic.service.ProjectHouseTypeService;
import com.emm.yixun.basic.service.ProjectRoomService;
import com.emm.yixun.basic.service.ProjectService;
import com.emm.yixun.basic.service.UserService;
import com.emm.yixun.basic.service.UserTokenService;
import com.emm.yixun.basic.service.VersionService;
import com.emm.yixun.common.app.AddProblemFeedbackReqDto;
import com.emm.yixun.common.app.AddProblemFeedbackResDto;
import com.emm.yixun.common.app.DownloadNewVersionReqDto;
import com.emm.yixun.common.app.DownloadNewVersionResDto;
import com.emm.yixun.common.app.EditMemberInfoReqDto;
import com.emm.yixun.common.app.EditMemberInfoResDto;
import com.emm.yixun.common.app.EditPwdReqDto;
import com.emm.yixun.common.app.EditPwdResDto;
import com.emm.yixun.common.app.GetCalculatePriceReqDto;
import com.emm.yixun.common.app.GetCalculatePriceResDto;
import com.emm.yixun.common.app.GetDictionaryListReqDto;
import com.emm.yixun.common.app.GetDictionaryListResDto;
import com.emm.yixun.common.app.GetMemberInfoReqDto;
import com.emm.yixun.common.app.GetMemberInfoResDto;
import com.emm.yixun.common.app.GetNoticeCategoryListReqDto;
import com.emm.yixun.common.app.GetNoticeCategoryListResDto;
import com.emm.yixun.common.app.GetNoticeDetailResDto;
import com.emm.yixun.common.app.GetNoticeDetilReqDto;
import com.emm.yixun.common.app.GetNoticeListReqDto;
import com.emm.yixun.common.app.GetNoticeListResDto;
import com.emm.yixun.common.app.GetProvinceCityAreaReqDto;
import com.emm.yixun.common.app.GetProvinceCityAreaResDto;
import com.emm.yixun.common.app.GetRemindCategoryListReqDto;
import com.emm.yixun.common.app.GetRemindCategoryListResDto;
import com.emm.yixun.common.app.GetRemindListReqDto;
import com.emm.yixun.common.app.GetRemindListResDto;
import com.emm.yixun.common.app.GetVersionReqDto;
import com.emm.yixun.common.app.GetVersionResDto;
import com.emm.yixun.common.app.LoginReqDto;
import com.emm.yixun.common.app.LoginResDto;
import com.emm.yixun.common.app.LogoutReqDto;
import com.emm.yixun.common.app.LogoutResDto;
import com.emm.yixun.common.app.RemoteLoginReqDto;
import com.emm.yixun.common.app.RemoteLoginResDto;
import com.emm.yixun.common.app.servletentity.DictionaryListRes;
import com.emm.yixun.common.app.servletentity.LoginHandImgListRes;
import com.emm.yixun.common.app.servletentity.NoticeList;
import com.emm.yixun.common.app.servletentity.ProblemImageListRes;
import com.emm.yixun.common.app.servletentity.ProvinceCityAreaList;
import com.emm.yixun.common.app.servletentity.RemindCategoryList;
import com.emm.yixun.common.app.servletentity.RemindList;
import com.emm.yixun.common.enums.ImageTypeEnum;
import com.emm.yixun.common.enums.ResultEnum;
import com.emm.yixun.common.exception.XFUNExceptionCode;
import com.emm.yixun.common.model.Area;
import com.emm.yixun.common.model.BaseCodeType;
import com.emm.yixun.common.model.BaseCodeValue;
import com.emm.yixun.common.model.Merchant;
import com.emm.yixun.common.model.Notice;
import com.emm.yixun.common.model.ProblemFeedback;
import com.emm.yixun.common.model.Project;
import com.emm.yixun.common.model.ProjectHouseType;
import com.emm.yixun.common.model.ProjectRoom;
import com.emm.yixun.common.model.Resources;
import com.emm.yixun.common.model.User;
import com.emm.yixun.common.model.UserToken;
import com.emm.yixun.common.model.Version;
import com.emm.yixun.common.model.appDto.CustomerCountDto;
import com.emm.yixun.common.model.appDto.NoticeListDto;
import com.emm.yixun.common.model.dto.AreaDto;
import com.emm.yixun.common.model.dto.BaseCodeTypeDto;
import com.emm.yixun.common.model.dto.BaseCodeValueDto;
import com.emm.yixun.common.model.dto.BusinessRelationDto;
import com.emm.yixun.common.model.dto.ImageDto;
import com.emm.yixun.common.model.dto.NoticeDto;
import com.emm.yixun.common.model.dto.PriceRecordDto;
import com.emm.yixun.common.model.dto.ProblemFeedbackDto;
import com.emm.yixun.common.model.dto.ProjectDto;
import com.emm.yixun.common.model.dto.UserDto;
import com.emm.yixun.common.model.dto.UserResourcesDto;
import com.emm.yixun.common.model.dto.UserTokenDto;
import com.emm.yixun.common.model.dto.VersionDto;
import com.emm.yixun.common.model.enums.BaseCodeTypeConvertEnum;
import com.emm.yixun.common.model.enums.DelFlagEnum;
import com.emm.yixun.common.model.enums.DictionaryTypeEnum;
import com.emm.yixun.common.model.enums.ImgTypeEnum;
import com.emm.yixun.common.model.enums.IsAvlidEnum;
import com.emm.yixun.common.model.enums.IsReadEnum;
import com.emm.yixun.common.model.enums.PropertyTypeEnum;
import com.emm.yixun.common.model.enums.RelationTypeEnum;
import com.emm.yixun.common.model.enums.StatusEnum;
import com.emm.yixun.common.page.Page;
import com.emm.yixun.common.page.PageUtil;
import com.emm.yixun.common.utils.FileUploadPorxyUtil;
import com.emm.yixun.common.utils.PasswordUtil;
import com.emm.yixun.common.utils.SequencesGenerator;
import com.emm.yixun.system.service.UserTokenServiceFacade;
import com.emm.yixun.system.service.app.UserServiceAppFacade;

@Service("userServiceAppFacade")
@WebService(endpointInterface="com.emm.yixun.system.service.app.UserServiceAppFacade")
public class UserServiceAppFacadeImpl implements UserServiceAppFacade{
	@Autowired
	private UserService userService;
	@Autowired
	private MerchantService merchantService;
	@Autowired
	private NoticeMapper noticeMapper;
	@Autowired
	private NoticeService noticeService;
	@Autowired
	private AreaService areaService;
	@Autowired
	private UserTokenService userTokenService;
	@Autowired
	private UserTokenMapper userTokenMapper;
	@Autowired
	private AppPushService appPushService;
	@Autowired
	private VersionMapper versionMapper;
	@Autowired
	private VersionService versionService;
	@Autowired
	private ProblemFeedbackService problemFeedbackService;
	@Autowired
	private ImageService imageService;
	@Autowired
	private ProjectRoomService projectRoomService;
	@Autowired
	private ProjectService projectService;
	@Autowired
	private ProjectHouseTypeService projectHouseTypeService;
	@Autowired
	private PriceRecordService priceRecordService;
	@Autowired
	private MerchantResourcesService merchantResourcesService;
	@Autowired
	private BusinessRelationService businessRelationService;
	@Autowired
	private BaseCodeTypeService baseCodeTypeService;
	@Autowired
	private BaseCodeValueService baseCodeValueService;
	@Autowired
	private UserTokenServiceFacade userTokenServiceFacade;

	
	@Value("${file.serviceUrl}")
	private String fileUploadUrl;
	
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
	SimpleDateFormat sdf_all = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	
	/**
     * login:(app登录接口) - serviceImpl
     * 
     * @author 作者(ny)
     * @param version  app版本号
     * @param loginName  用户名
     * @param loginPwd  登录密码
     * @param UUID  UUID
     * @param loginPlatform  登录平台：01代表 ios；02代表Android
     * @param terminalCode  终端编码
     * @return 
     */
	@Override
	public LoginResDto login_app(LoginReqDto reqDto) {
		LoginResDto resDto = new LoginResDto();
		try{
			//用户登录名：手机号码验证
			UserDto entity = new UserDto();
			entity.setUserPhone(reqDto.getLoginName());
			User user = userService.selectByDto(entity);
			if(null != user){
				//判断是否OA账户
				//OA账户只能使用user_account登录,手机号禁用
				String oaUserCode = user.getOaUserCode();
				if(StringUtils.isNotEmpty(oaUserCode)){
					user = userService.loginWithAccountOnly(entity);
				}
			}
			
			//查询用户是否存在，如返回null则给出异常提示信息
			if(user == null){
				resDto.setResult(ResultEnum.FAILURE.getNo());
				resDto.setErrorCode(XFUNExceptionCode.USER_UNEXIST.getCode());
				resDto.setErrorMsg(XFUNExceptionCode.USER_UNEXIST.getDesin());
				return resDto;
			}

			// 校验商户是否有效
			Merchant merchant = merchantService.selectById(user.getMerchantId());
			if(null == merchant || DelFlagEnum.DEL.getNo().equals(merchant.getDelFlag())){
				resDto.setResult(ResultEnum.FAILURE.getNo());
				resDto.setErrorCode(XFUNExceptionCode.UNMERCHANT.getCode());
				resDto.setErrorMsg(XFUNExceptionCode.UNMERCHANT.getDesout());
				return resDto;
			}
			//校验账号状态是否已冻结
			if("1".equals(user.getUserStatus())){
				resDto.setResult(ResultEnum.FAILURE.getNo());
				resDto.setErrorCode(XFUNExceptionCode.USER_FROZEN.getCode());
				resDto.setErrorMsg(XFUNExceptionCode.USER_FROZEN.getDesin());
				return resDto;
			}

			//校验密码是否正确
			String password2 = "";
			String originPassword = reqDto.getLoginPwd();
			//第二密码
			//由于绿城OA推送的密码,不包含emm前缀,当登录M2系统登录时,不去掉emm前缀加密,永远无法登录
			//临时解决方案.搞第二验证密码,第一个不通过,验证第二个
			password2 = DigestUtils.md5Hex(getContentBytes(originPassword, "utf-8"));
			String userPassword = user.getUserPassword().toUpperCase();
			if(!PasswordUtil.md5Hex(originPassword).toUpperCase().equals(userPassword)){//用户名或密码错误
				//账户密码加密,去掉emm前缀.
				password2 = password2.toUpperCase();
				if (!password2.equals(userPassword)) {
					resDto.setResult(ResultEnum.FAILURE.getNo());
					resDto.setErrorCode(XFUNExceptionCode.USER_USERORPWDERROR.getCode());
					resDto.setErrorMsg(XFUNExceptionCode.USER_USERORPWDERROR.getDesin());
					return resDto;
				}
			}
			
			resDto.setMerchantId(String.valueOf(user.getMerchantId()));//商家Id
			resDto.setUserId(String.valueOf(user.getId()));//用户Id
			resDto.setUserCode(user.getUserCode());//用户Code
			resDto.setUserName(user.getUserName());//用户名称
			
			/**
			 * 查询该用户所属商户是否已开通
			 * 类型：类型type=1代表是否开通电话平台；类型type=2代表是否开通认筹
			 * 是否开通：0、未开通；1、已开通
			 */
			if(merchant.getPhoneInformation() != null && !"".equals(merchant.getPhoneInformation())){
				String isPhoneInformation = merchant.getPhoneInformation();
				JSONArray jsonArray=JSON.parseArray(isPhoneInformation);
				for(int i=0;i<jsonArray.size();i++){
					JSONObject row=jsonArray.getJSONObject(i);
					if("1".equals(row.getString("type"))){//type类型等于“1”代表电话平台
						resDto.setIsPhoneInformation(row.getString("status"));
					}else if("2".equals(row.getString("type"))){//type类型等于“2”代表是否开通认筹
						resDto.setIsPaydeposit(row.getString("status"));
					}
				}
			}else{
				resDto.setIsPhoneInformation("0");
				resDto.setIsPaydeposit("0");
			}
			
			/**
			 * 菜单权限
			 */
			UserResourcesDto userResourcesDto = new UserResourcesDto();
			//userResourcesDto.setResourcesLevel("0");
			//app端标示
			userResourcesDto.setResourcesType("2");
			userResourcesDto.setMerchantId(user.getMerchantId());
			List<Resources> responseList = null;
			if(user.getIsAdmin().equals("1")){
				responseList = merchantResourcesService.findUserResources(userResourcesDto);
			}else{
				userResourcesDto.setRoleId(String.valueOf(user.getRoleId()));
				responseList = merchantResourcesService.findRoleResources(userResourcesDto);
			}
			Map<String, String> roleResourcesMap = new HashMap<>();
			if(null != responseList && responseList.size() > 0){
				for(Resources resources: responseList){
					roleResourcesMap.put(resources.getResourcesCode(), resources.getResourcesCode());
				}
			}

			int isHomePage=0,isCustomer=0,isDistributionCustomer=0;
			int isHouses=0,isAnalysis=0,isMine=0,isAddCustomer=0;
			int isGradesMine=0,isHeroListMine=0,isTeamRankingMine=0;
			int isAddPaydeposit=0, isAddSubscribe=0, isAddSigned=0;
			if(null != responseList && responseList.size() > 0){
				/**
				 * 菜单权限：
				 *  1、resources_code值不为空并且等于 menu_0100，代表有首页菜单权限
				 *  2、resources_code值不为空并且等于 menu_0101，代表有首页客户权限
				 *  	2.1、menu_0101_0002: 客户新增权限
				 *  	2.2、menu_0101_0004: 客户分配权限
				 *  3、resources_code值不为空并且等于 menu_0102，代表有首页房源权限
				 *  4、resources_code值不为空并且等于 menu_0103，代表有首页分析权限
				 *  5、resources_code值不为空并且等于 menu_0104，代表有首页我的权限
				 *  6、resources_code值不为空并且等于 menu_0105, 代表有营销管理权限
				 *  	6.1、menu_0105_0001: 新增认筹权限
				 *  	6.2、menu_0105_0002: 新增认购权限
				 *  	6.3、menu_0105_0003: 新增签约权限
				 */
				// 首页模块
				if(null != roleResourcesMap.get("menu_0100") && "menu_0100".equals(roleResourcesMap.get("menu_0100"))){
					isHomePage = 1;
				}
				// 客源模块
				if(null != roleResourcesMap.get("menu_0101") && "menu_0101".equals(roleResourcesMap.get("menu_0101"))){
					isCustomer = 1;
					// 新增客户
					if(null != roleResourcesMap.get("menu_0101_0002") && "menu_0101_0002".equals(roleResourcesMap.get("menu_0101_0002"))){
						isAddCustomer = 1;
					}
					// 分配客户
					if(null != roleResourcesMap.get("menu_0101_0004") && "menu_0101_0004".equals(roleResourcesMap.get("menu_0101_0004"))){
						isDistributionCustomer = 1;
					}
				}
				// 房源模块
				if(null != roleResourcesMap.get("menu_0102") && "menu_0102".equals(roleResourcesMap.get("menu_0102"))){
					isHouses = 1;
				}
				// 分析模块
				if(null != roleResourcesMap.get("menu_0103") && "menu_0103".equals(roleResourcesMap.get("menu_0103"))){
					isAnalysis = 1;
				}
				// 我的模块
				if(null != roleResourcesMap.get("menu_0104") && "menu_0104".equals(roleResourcesMap.get("menu_0104"))){
					isMine = 1;
					// 我的成绩
					if(null != roleResourcesMap.get("menu_0104_0001") && "menu_0104_0001".equals(roleResourcesMap.get("menu_0104_0001"))){
						isGradesMine = 1;
					}
					// 个人英雄榜
					if(null != roleResourcesMap.get("menu_0104_0002") && "menu_0104_0002".equals(roleResourcesMap.get("menu_0104_0002"))){
						isHeroListMine = 1;
					}
					// 团队排名
					if(null != roleResourcesMap.get("menu_0104_0003") && "menu_0104_0003".equals(roleResourcesMap.get("menu_0104_0003"))){
						isTeamRankingMine = 1;
					}
				}
				// 营销模块
				if(null != roleResourcesMap.get("menu_0105") && "menu_0105".equals(roleResourcesMap.get("menu_0105"))){
					// 新增认筹
					if(null != roleResourcesMap.get("menu_0105_0001") && "menu_0105_0001".equals(roleResourcesMap.get("menu_0105_0001"))){
						isAddPaydeposit = 1;
					}
					// 新增认购
					if(null != roleResourcesMap.get("menu_0105_0002") && "menu_0105_0002".equals(roleResourcesMap.get("menu_0105_0002"))){
						isAddSubscribe = 1;
					}
					// 新增签约
					if(null != roleResourcesMap.get("menu_0105_0003") && "menu_0105_0003".equals(roleResourcesMap.get("menu_0105_0003"))){
						isAddSigned = 1;
					}
				}

			}
			resDto.setIsHomePage(String.valueOf(isHomePage));//首页
			
			resDto.setIsCustomer(String.valueOf(isCustomer));//客户
			resDto.setIsAddCustomer(String.valueOf(isAddCustomer));//新增客户
			resDto.setIsDistributionCustomer(String.valueOf(isDistributionCustomer));//分配客户
			
			resDto.setIsHouses(String.valueOf(isHouses));//房源
			resDto.setIsAnalysis(String.valueOf(isAnalysis));//分析

			resDto.setIsAddPaydeposit(String.valueOf(isAddPaydeposit));
			resDto.setIsAddSubscribe(String.valueOf(isAddSubscribe));
			resDto.setIsAddSigned(String.valueOf(isAddSigned));
			
			resDto.setIsMine(String.valueOf(isMine));//我的
			resDto.setIsGradesMine(String.valueOf(isGradesMine));//我的成绩
			resDto.setIsHeroListMine(String.valueOf(isHeroListMine));//个人英雄榜
			resDto.setIsTeamRankingMine(String.valueOf(isTeamRankingMine));//团队排名
			
			//token生成
			String token = SequencesGenerator.getUUID(String.valueOf(user.getId()));
			resDto.setToken(token);//登录token
			
			//新增用户推送数据【消息推送业务逻辑处理：两台设备同时登录】
			String [] terminalInfos = reqDto.getTerminalCode().split("\\|");
			UserTokenDto ut_entity = new UserTokenDto();
			ut_entity.setUserId(user.getId());//用户Id
			ut_entity.setStatus(StatusEnum.LOGINED.getNo());
			List<UserToken> userTokenList = userTokenService.selectListByDto(ut_entity);
			if(userTokenList.size() > 0){
				//两台设备同时登录一个账号推送push消息
				if(!terminalInfos[0].equals(userTokenList.get(0).getUuid())){
					SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
					Map<String, String> jsonMap = new HashMap<String, String>();
					jsonMap.put("name", "异地登录");
					JSONObject jsonObject = (JSONObject) JSONObject.toJSON(jsonMap);
					String json = jsonObject.toString();
					Map<String, String> map = new HashMap<String, String>();
					map.put("Data", json);
					map.put("pushType", "yddl");
					UserToken menber = (UserToken)userTokenList.get(0);
					String type = "";
					if("1".equals(terminalInfos[1])){
						type = "Android";
					}else if("2".equals(terminalInfos[1])){
						type = "iOS";
					}
					//被踢设备接收push消息
					String text = "亲，您的账号于"+sdf.format(new Date())+"在一台"+type+"手机登录。\n如非本人操作，则密码可能已泄漏，建议修改密码。";
					appPushService.pushMessage(String.valueOf(menber.getUserId()), text, null, map);//两台设备同时登录，极光推送push消息给用户
				}
				//更新记录信息
				ut_entity.setId(userTokenList.get(0).getId());//ID
				ut_entity.setUuid(terminalInfos[0]);//设备号
				ut_entity.setStatus(StatusEnum.OTHERLOGIN.getNo());//状态：2、在其他设备登录
				ut_entity.setUpdateUserId(user.getId());//修改人Id：默认当前登录人Id
				userTokenService.update(ut_entity);
			}
			//新增记录信息
			UserTokenDto userTokenDto = new UserTokenDto();
			if(reqDto.getDeviceToken() == null || "".equals(reqDto.getDeviceToken())){
				userTokenDto.setDeviceToken("12345678");//极光推送唯一标识deviceToken
			}else{
				userTokenDto.setDeviceToken(reqDto.getDeviceToken());//极光推送唯一标识deviceToken
			}
			userTokenDto.setDeviceVersion(terminalInfos[2]);//手机操作系统版本号
			//软件安装时间撮
			String deviceTimestamp = new String(terminalInfos[3]);
			SimpleDateFormat sdf_device = new SimpleDateFormat("yyyyMMddHHmmss");
			userTokenDto.setUserId(user.getId());//用户ID
			userTokenDto.setDeviceTime(sdf_device.parse(deviceTimestamp.toString()));
			userTokenDto.setDeviceType(terminalInfos[1]);//系统类型：1、安卓；2、iOS
			userTokenDto.setIsAvlid(IsAvlidEnum.AVILD.getNo());//是否有效：0、无效；1、有效
			userTokenDto.setUuid(terminalInfos[0]);//设备号
			userTokenDto.setStatus(StatusEnum.LOGINED.getNo());//状态：1、已登录
			userTokenDto.setCreateUserId(user.getId());//创建人Id：默认当前登录人Id
			userTokenDto.setCreateTime(new Date());//创建时间：默认系统当前时间
			userTokenDto.setDelFlag(DelFlagEnum.UNDEL.getNo());//是否删除：0、未删除
			userTokenDto.setUpdateTime(new Date());//修改时间：默认系统当前时间
			userTokenDto.setMerchantId(String.valueOf(user.getMerchantId()));//商户Id
			userTokenService.create(userTokenDto);
			
			//首页logo图片列表
			List<LoginHandImgListRes> loginHandImgList = new ArrayList<LoginHandImgListRes>();
			LoginHandImgListRes loginHandImgListRes = new LoginHandImgListRes();
			LoginHandImgListRes loginHandImgListRes2 = new LoginHandImgListRes();
			LoginHandImgListRes loginHandImgListRes3 = new LoginHandImgListRes();
			if("1".equals(terminalInfos[1])){
				loginHandImgListRes.setHandLogoImg(buildLogoUrl(merchant.getAppLogo(), "android", null));
				loginHandImgList.add(loginHandImgListRes);
			}else{
				loginHandImgListRes.setHandLogoImg(buildLogoUrl(merchant.getAppLogo(), "ios", "1"));
				loginHandImgList.add(loginHandImgListRes);
				loginHandImgListRes2.setHandLogoImg(buildLogoUrl(merchant.getAppLogo(), "ios", "2"));
				loginHandImgList.add(loginHandImgListRes2);
				loginHandImgListRes3.setHandLogoImg(buildLogoUrl(merchant.getAppLogo(), "ios", "3"));
				loginHandImgList.add(loginHandImgListRes3);
			}
			resDto.setLoginHandImgList(loginHandImgList);
			//当返回给客户端，删除需要重新登陆的标示
			userTokenServiceFacade.removeReLogin(String.valueOf(user.getId()));
		}catch(Exception e){
			e.printStackTrace();
		}
		resDto.setResult(ResultEnum.SUCCESS.getNo());
		return resDto;
	}

	/**
     * editPwd:(app修改密码接口) - serviceImpl
     * 
     * @author 作者(ny)
     * @param version  app版本号
     * @param merchantId  商家Id
     * @param userId 用户Id
     * @param token 会话token
     * @param loginPwd  原密码
     * @param newPwd  新密码
     * @param terminalCode  终端编码
     * @return 
     */
	@Override
	public EditPwdResDto editPwd(EditPwdReqDto reqDto) {
		EditPwdResDto resDto = new EditPwdResDto();
		UserDto entity = new UserDto();
		entity.setId(Long.valueOf(reqDto.getUserId()));//用户Id
		entity.setMerchantId(Long.valueOf(reqDto.getMerchantId()));//商户Id
		User user = userService.selectByDto(entity);
		//查询用户是否存在，如返回null则给出异常提示信息
		if(user == null){
			resDto.setResult(ResultEnum.FAILURE.getNo());
			resDto.setErrorCode(XFUNExceptionCode.USER_UNEXIST.getCode());
			resDto.setErrorMsg(XFUNExceptionCode.USER_UNEXIST.getDesin());
			return resDto;
		}
		//校验原密码是否正确
//		if(!PasswordUtil.md5Hex(reqDto.getLoginPwd()).equals(user.getUserPassword())){
//			resDto.setResult(ResultEnum.FAILURE.getNo());
//			resDto.setErrorCode(XFUNExceptionCode.USER_PWDERROR.getCode());
//			resDto.setErrorMsg(XFUNExceptionCode.USER_PWDERROR.getDesin());
//			return resDto;
//		}
		//校验密码是否正确
		String password2 = "";
		String originPassword = reqDto.getLoginPwd();
		//第二密码
		//由于绿城OA推送的密码,不包含emm前缀,当登录M2系统登录时,不去掉emm前缀加密,永远无法登录
		//临时解决方案.搞第二验证密码,第一个不通过,验证第二个
		password2 = DigestUtils.md5Hex(getContentBytes(originPassword, "utf-8"));
		String userPassword = user.getUserPassword().toUpperCase();
		if(!PasswordUtil.md5Hex(originPassword).toUpperCase().equals(userPassword)){//用户名或密码错误
			//账户密码加密,去掉emm前缀.
			password2 = password2.toUpperCase();
			if (!password2.equals(userPassword)) {
				resDto.setResult(ResultEnum.FAILURE.getNo());
				resDto.setErrorCode(XFUNExceptionCode.USER_USERORPWDERROR.getCode());
				resDto.setErrorMsg(XFUNExceptionCode.USER_USERORPWDERROR.getDesin());
				return resDto;
			}
		}


		//业务修改处理
		entity.setMerchantId(Long.valueOf(reqDto.getMerchantId()));//商户Id
		entity.setUserPassword(PasswordUtil.md5Hex(reqDto.getNewPwd()));//新密码MD5加密
		int count = userService.update(entity);
		//密码修改失败返回错误信息
		if(count < 1){
			resDto.setResult(ResultEnum.FAILURE.getNo());
			resDto.setErrorCode(XFUNExceptionCode.USER_EDITPWDFAILURE.getCode());
			resDto.setErrorMsg(XFUNExceptionCode.USER_EDITPWDFAILURE.getDesin());
			return resDto;
		}
		resDto.setResult(ResultEnum.SUCCESS.getNo());
		return resDto;
	}

	/**
     * logout:(app退出登录接口) - serviceImpl
     * 
     * @author 作者(ny)
     * @param version  app版本号
     * @param merchantId  商家Id
     * @param logoutName  用户名
     * @param token 会话token
     * @param terminalCode  终端编码
     * @return 
     */
	@Override
	public LogoutResDto logout(LogoutReqDto reqDto) {
		LogoutResDto resDto = new LogoutResDto();
		UserDto entity = new UserDto();
		entity.setId(Long.valueOf(reqDto.getUserId()));//用户Id
		entity.setMerchantId(Long.valueOf(reqDto.getMerchantId()));//商户Id
		User user = userService.selectByDto(entity);
		//查询用户是否存在，如返回null则给出异常提示信息
		if(user == null){
			resDto.setResult(ResultEnum.FAILURE.getNo());
			resDto.setErrorCode(XFUNExceptionCode.USER_UNEXIST.getCode());
			resDto.setErrorMsg(XFUNExceptionCode.USER_UNEXIST.getDesin());
			return resDto;
		}
		//修改userToken状态status等于：0 未登录
		UserTokenDto ut_entity = new UserTokenDto();
		ut_entity.setUserId(user.getId());//用户Id
		ut_entity.setStatus(StatusEnum.LOGINED.getNo());
		List<UserToken> userTokenList = userTokenService.selectListByDto(ut_entity);
		if(userTokenList != null && userTokenList.size() > 0){
			for(UserToken userToken : userTokenList){
				UserTokenDto utDto = new UserTokenDto();
				utDto.setId(userToken.getId());
				utDto.setStatus(StatusEnum.UNLOGIN.getNo());
				utDto.setUpdateUserId(user.getId());
				userTokenService.update(utDto);
			}
		}
		resDto.setResult(ResultEnum.SUCCESS.getNo());
		return resDto;
	}

	/**
    * getMemberInfo:( 个人设置类-app查询会员信息接口) - serviceImpl
    * 
    * @author 作者(ny)
    * @param version  app版本号
    * @param merchantId  商家Id
    * @param logoutName  用户名
    * @param token 会话token
    * @param terminalCode  终端编码
    * @return 
    */
	@Override
	public GetMemberInfoResDto getMemberInfo(GetMemberInfoReqDto reqDto) {
		GetMemberInfoResDto resDto = new GetMemberInfoResDto();
		//根据商户Id与用户Id查询用户信息
		UserDto entity = new UserDto();
		entity.setId(Long.valueOf(reqDto.getUserId()));
		entity.setMerchantId(Long.valueOf(reqDto.getMerchantId()));
		User user = userService.selectByDto(entity);
		if(user == null){
			resDto.setResult(ResultEnum.FAILURE.getNo());
			resDto.setErrorCode(XFUNExceptionCode.USER_UNEXIST.getCode());
			resDto.setErrorMsg(XFUNExceptionCode.USER_UNEXIST.getDesin());
			return resDto;
		}
		if(user.getHeadPic() != null && !"".equals(user.getHeadPic())){
			resDto.setHeadPic(user.getHeadPic());//头像
		}else{
			resDto.setHeadPic(null);//头像
		}
		if(user.getBirthday() != null && !"".equals(user.getBirthday())){
			resDto.setBirthday(sdf.format(user.getBirthday()));//生日
		}else{
			resDto.setBirthday(null);
		}
		if(user.getEntryTime() != null && !"".equals(user.getEntryTime())){
			resDto.setEntryTime(sdf.format(user.getEntryTime()));//入职时间
		}else{
			resDto.setEntryTime(null);
		}
		resDto.setName(user.getUserName());//名称
		resDto.setMobile(user.getUserPhone());//手机号码
		resDto.setResult(ResultEnum.SUCCESS.getNo());
		return resDto;
	}

	 /**
    * editMemberInfo:( 个人设置类-app修改会员信息接口) - serviceImpl
    * 
    * @author 作者(ny)
    * @param version  app版本号
    * @param merchantId  商家Id
    * @param logoutName  用户名
    * @param token 会话token
    * @param headPic 头像
    * @param headType 上传头像类型
    * @param terminalCode  终端编码
    * @return 
    */
	@Override
	public EditMemberInfoResDto editMemberInfo(EditMemberInfoReqDto reqDto) {
		EditMemberInfoResDto resDto = new EditMemberInfoResDto();
		//校验图片格式
		@SuppressWarnings("unused")
		ImageTypeEnum imgType = null;
		if(reqDto.getHeadType() == null || !"".equals(reqDto.getHeadType())){
			if (".PNG".equals(reqDto.getHeadType()) || ".png".equals(reqDto.getHeadType())) {
				imgType = ImageTypeEnum.png;
			} else if (".JPEG".equals(reqDto.getHeadType()) || ".jpeg".equals(reqDto.getHeadType())) {
				imgType = ImageTypeEnum.jpeg;
			} else if (".JPG".equals(reqDto.getHeadType()) || ".jpg".equals(reqDto.getHeadType())) {
				imgType = ImageTypeEnum.jpg;
			} else {
				resDto.setResult(ResultEnum.FAILURE.getNo());
				resDto.setErrorCode(XFUNExceptionCode.EDIT_USER_HEADTTPE_ERROR.getCode());
				resDto.setErrorMsg(XFUNExceptionCode.EDIT_USER_HEADTTPE_ERROR.getDesin());
				return resDto;
			}
		}
		//保存更新图片
		String imgName=SequencesGenerator.getUUID("IMG")+reqDto.getHeadType();
		String result=FileUploadPorxyUtil.appPost(fileUploadUrl,reqDto.getHeadPic(),imgName);
		JSONObject resultJson=JSON.parseObject(result);
		String postResult=resultJson.getString("result");
		if(!"1".equals(postResult)){
			resDto.setResult(ResultEnum.FAILURE.getNo());
			resDto.setErrorCode(XFUNExceptionCode.EDIT_USER_HEADPIC_FAIL.getCode());
			resDto.setErrorMsg(XFUNExceptionCode.EDIT_USER_HEADPIC_FAIL.getDesin());
			return resDto;
		}
		String postUrl=resultJson.getString("url");
		UserDto userDto=new UserDto();
		userDto.setId(Long.valueOf(reqDto.getUserId()));
		userDto.setHeadPic(postUrl);
		int count=userService.update(userDto);
		if(count>0){
			resDto.setResult(ResultEnum.SUCCESS.getNo());
		}else{
			resDto.setResult(ResultEnum.FAILURE.getNo());
			resDto.setErrorCode(XFUNExceptionCode.EDIT_USER_HEADPIC_FAIL.getCode());
			resDto.setErrorMsg(XFUNExceptionCode.EDIT_USER_HEADPIC_FAIL.getDesin());
		}
		
		return resDto;
	}

	/**
	    * getNoticeList:( 系统类-app查询公告列表接口) - serviceImpl
	    * 
	    * @author 作者(ny)
	    * @param version  app版本号
	    * @param merchantId  商家Id
	    * @param logoutName  用户名
	    * @param token 会话token
	    * @param projectCode 项目code
	    * @param noticeCategoryId 公告分类Id
	    * @param terminalCode  终端编码
	    * @return 
	    */
	@Override
	public GetNoticeListResDto getNoticeList(GetNoticeListReqDto reqDto) {
		GetNoticeListResDto resDto = new GetNoticeListResDto();
		CustomerCountDto customerCountDto = new CustomerCountDto();
		customerCountDto.setMerchantId(String.valueOf(reqDto.getMerchantId()));//商家Id
		customerCountDto.setProjectCode(reqDto.getProjectCode());//项目Code
		customerCountDto.setNoticeType(DictionaryTypeEnum.NOTICE.getNo());//消息类型：公告
		//公告类别Id
		if(StringUtils.isNotEmpty(reqDto.getNoticeCategoryId())){
			customerCountDto.setNotCateId(reqDto.getNoticeCategoryId());
		}
		//查询公告列表
		List<NoticeListDto> noticeListDto = noticeMapper.selectNoticeList(customerCountDto);
		List<NoticeList> noticeList = new ArrayList<NoticeList>();
		if(noticeListDto.size() > 0){
			for(int i=0;i<noticeListDto.size();i++){
				NoticeList notice = new NoticeList();
				notice.setNoticeId(noticeListDto.get(i).getNoticeId());//公告Id
				notice.setNoticeCategory(noticeListDto.get(i).getNoticeCategory());//公告类别
				notice.setNoticeDate(sdf.format(noticeListDto.get(i).getNoticeDate()));//公告发布日期
				notice.setNoticeTitle(noticeListDto.get(i).getNoticeTitle());//公告内容
				if("0".equals(noticeListDto.get(i).getIsRead())){
					notice.setIsRead("未读");
				}else{
					notice.setIsRead("已读");
				}
				noticeList.add(notice);
			}
			resDto.setNoticeList(noticeList);
		}else{
			resDto.setNoticeList(null);
		}
		resDto.setResult(ResultEnum.SUCCESS.getNo());
		return resDto;
	}

	 /**
	    * getNoticeDetail:( 系统类-app查询公告分类列表接口) - serviceImpl
	    * 
	    * @author 作者(ny)
	    * @param version  app版本号
	    * @param merchantId  商家Id
	    * @param logoutName  用户名
	    * @param token 会话token
	    * @param projectCode 项目code
	    * @param noticeId 公告Id
	    * @param terminalCode  终端编码
	    * @return 
	    */
	@Override
	public GetNoticeDetailResDto getNoticeDetail(
			GetNoticeDetilReqDto reqDto) {
		GetNoticeDetailResDto resDto = new GetNoticeDetailResDto();
		Notice notice = noticeService.selectById(Long.valueOf(reqDto.getNoticeId()));
		if(notice == null){
			resDto.setNoticeDate(null);
			resDto.setNoticeContent(null);
			resDto.setNoticeTitle(null);
		}else{
			if("0".equals(notice.getIsRead())){
				NoticeDto ncDto = new NoticeDto();
				ncDto.setId(Long.valueOf(reqDto.getNoticeId()));
				ncDto.setIsRead(IsReadEnum.READ.getNo());
				ncDto.setUpdateUserId(Long.valueOf(reqDto.getUserId()));
				ncDto.setUpdateTime(new Date());
				noticeService.update(ncDto);
			}
			resDto.setNoticeDate(sdf.format(notice.getIssueTime()));//公告日期
			resDto.setNoticeContent(notice.getContent());//公告内容
			resDto.setNoticeTitle(notice.getTitle());//公告标题
		}
		resDto.setResult(ResultEnum.SUCCESS.getNo());
		return resDto;
	}

	/**
	    * getRemindList:( 系统类-app查询提醒列表接口) - serviceImpl
	    * 
	    * @author 作者(ny)
	    * @param version  app版本号
	    * @param merchantId  商家Id
	    * @param logoutName  用户名
	    * @param token 会话token
	    * @param projectCode 项目code
	    * @param terminalCode  终端编码
	    * @return 
	    */
	@Override
	public GetRemindListResDto getRemindList(GetRemindListReqDto reqDto) {
		GetRemindListResDto resDto = new GetRemindListResDto();
		CustomerCountDto customerCountDto = new CustomerCountDto();
		customerCountDto.setMerchantId(String.valueOf(reqDto.getMerchantId()));//商家Id
		customerCountDto.setProjectCode(reqDto.getProjectCode());//项目Code
		User user = userService.selectById(Long.valueOf(reqDto.getUserId()));
		customerCountDto.setUserCode(user.getUserCode());
		customerCountDto.setUserId(String.valueOf(user.getId()));
		List<NoticeListDto> noticeListDto = noticeMapper.selectRemindList(customerCountDto);
		List<RemindList> remindList = new ArrayList<RemindList>();
		if(noticeListDto.size() > 0){
			for(int i=0;i<noticeListDto.size();i++){
				RemindList remind = new RemindList();
				remind.setRemindCategoryId(String.valueOf(noticeListDto.get(i).getNoticeCategoryId()));//提醒类别Id
				remind.setRemindCategory(noticeListDto.get(i).getNoticeCategory());//提醒类型
				remind.setRemindDate(sdf.format(noticeListDto.get(i).getNoticeDate()));//提醒时间
				remind.setRemindContent(noticeListDto.get(i).getNoticeContent());//提醒内容
				if("0".equals(noticeListDto.get(i).getIsRead())){
					remind.setIsRead("未读");
				}else{
					remind.setIsRead("已读");
				}
				remindList.add(remind);
			}
			resDto.setRemindList(remindList);
		}else{
			resDto.setRemindList(null);
		}
		resDto.setResult(ResultEnum.SUCCESS.getNo());
		return resDto;
	}

	   /**
	    * getRemindCategoryList:( 系统类-app提醒分类列表接口) - serviceImpl
	    * 
	    * @author 作者(ny)
	    * @param version  app版本号
	    * @param merchantId  商家Id
	    * @param logoutName  用户名
	    * @param token 会话token
	    * @param projectCode 项目code
	    * @param remindCategory 提醒类别
	    * @param pageNumber 页码
	    * @param pageSize 页码大小
	    * @param terminalCode  终端编码
	    * @return 
	    */
	@Override
	public GetRemindCategoryListResDto getRemindCategoryList(
			GetRemindCategoryListReqDto reqDto) {
		GetRemindCategoryListResDto resDto = new GetRemindCategoryListResDto();
		NoticeDto entity = new NoticeDto();
		entity.setMerchantId(reqDto.getMerchantId());//商家Id
		entity.setProjectCode(reqDto.getProjectCode());//项目Code
		entity.setDictionaryId(Long.valueOf(reqDto.getRemindCategoryId()));//提醒类别Id
		entity.setNoticeType(DictionaryTypeEnum.REMIND.getNo());//消息类型：提醒
		/*User user = userService.selectById(Long.valueOf(reqDto.getUserId()));
		entity.setUserCode(user.getUserCode());*/
		entity.setUserCode(reqDto.getUserId());
		entity.setOrders(" t.issue_time desc ");
		String pageNumber = reqDto.getPageNumber();//页码
		String pageSize = reqDto.getPageSize();//页码大小
		Page<Notice> noticePage = noticeService.getNoticeList(entity, PageUtil.begin(Integer.parseInt(pageNumber) , Integer.parseInt(pageSize)), Integer.parseInt(pageSize));
		List<RemindCategoryList> remindCategoryList = new ArrayList<RemindCategoryList>();
		if(noticePage.getRows().size() >0){
			List<Notice> msgTempList = noticePage.getRows();
			for(int i=0;i<msgTempList.size();i++){
				RemindCategoryList rcList = new RemindCategoryList();
				rcList.setRemindContent(msgTempList.get(i).getContent());//提醒内容
				rcList.setRemindDate(sdf.format(msgTempList.get(i).getIssueTime()));//提醒时间
				remindCategoryList.add(rcList);
				//更新提醒消息状态为：已读
				if(IsReadEnum.UNREAD.getNo().equals(msgTempList.get(i).getIsRead())){
					NoticeDto noticeDto = new NoticeDto();
					noticeDto.setId(msgTempList.get(i).getId());
					noticeDto.setIsRead(IsReadEnum.READ.getNo());
					noticeDto.setUpdateUserId(Long.valueOf(reqDto.getUserId()));
					noticeService.update(noticeDto);
				}
			}
			resDto.setTotalPage(String.valueOf(noticePage.getTotalPages()));
			resDto.setTotalCount(String.valueOf(noticePage.getTotal()));
			resDto.setRemindCategoryList(remindCategoryList);
		}else{
			resDto.setTotalPage("0");
			resDto.setTotalCount("0");
			resDto.setRemindCategoryList(null);
		}
		resDto.setPageNumber(pageNumber);
		resDto.setPageSize(pageSize);
		resDto.setResult(ResultEnum.SUCCESS.getNo());
		return resDto;
	}

	   /**
	    * getProvinceCityArea:( 系统类-app省市区列表接口) - serviceImpl
	    * 
	    * @author 作者(ny)
	    * @param version  app版本号
	    * @param parentId  上级区域ID(为空返回所有省份)
	    * @param terminalCode  终端编码
	    * @return 
	    */
	@Override
	public GetProvinceCityAreaResDto getProvinceCityArea(
			GetProvinceCityAreaReqDto reqDto) {
		GetProvinceCityAreaResDto resDto = new GetProvinceCityAreaResDto();
		try{
			AreaDto entity = new AreaDto();
			entity.setDelFlag(DelFlagEnum.UNDEL.getNo());//删除状态：未删除
			AreaDto areaDto = new AreaDto();
			areaDto.setParentId(Long.valueOf(0));
			JSONArray newArray = new JSONArray(); 
			List<Area> areaList = areaService.selectListByDto(areaDto); //省
			
			for(int i = 0; i < areaList.size(); i++){
				Area area = (Area)areaList.get(i);
				String province = area.getAreaName();
				Long provinceId = area.getId();
				
				JSONObject jo_province = new JSONObject();
				jo_province.put("province", province);
				jo_province.put("provinceId", provinceId);
				JSONArray newArray_cities2 = new JSONArray(); 
				List<ProvinceCityAreaList> ct2 = getProvinceCity(provinceId);//市
				for(int l = 0; l < ct2.size(); l++){
					ProvinceCityAreaList pc2 = (ProvinceCityAreaList)ct2.get(l);
					String city = pc2.getProvinceCityAreaName();
					String cityId = pc2.getProvinceCityAreaId();
					
					JSONObject jo_city2 = new JSONObject();
					jo_city2.put("city", city);
					jo_city2.put("cityId", cityId);
					
					JSONArray newArray_districts = new JSONArray(); 
					List<ProvinceCityAreaList> ct3 = getProvinceCity(Long.parseLong(cityId));//区、县
					for(int t = 0; t < ct3.size(); t++){
						ProvinceCityAreaList pc3 = ct3.get(t);
						String district = pc3.getProvinceCityAreaName();
						String districtId = pc3.getProvinceCityAreaId();
						
						JSONObject jo_mapDist2 = new JSONObject();
						jo_mapDist2.put("district", district);
						jo_mapDist2.put("districtId", districtId);
						newArray_districts.add(jo_mapDist2);
					}
					jo_city2.put("districts", newArray_districts);
					newArray_cities2.add(jo_city2);
				}
				jo_province.put("cities", newArray_cities2);
				newArray.add(jo_province);
			}
	
			resDto.setProvinceCityAreaList(newArray.toString());
		}catch(Exception e){
			e.printStackTrace();
		}
		resDto.setResult(ResultEnum.SUCCESS.getNo());
		return resDto;
	}
	
	//省市区查询方法
	public List<ProvinceCityAreaList> getProvinceCity(Long parent){
 		List<ProvinceCityAreaList> provinceCityList = new ArrayList<ProvinceCityAreaList>();
 		AreaDto areaDto = new AreaDto();
 		areaDto.setParentId(parent);
		List<Area> list = areaService.selectListByDto(areaDto);
		for(int i = 0; i < list.size(); i++){
			Area area = (Area)list.get(i);
			ProvinceCityAreaList provinceCity = new ProvinceCityAreaList();
			provinceCity.setProvinceCityAreaId(String.valueOf(area.getId()));
			provinceCity.setProvinceCityAreaName(area.getAreaName());
			provinceCityList.add(provinceCity);
		}
 		return provinceCityList;
 	}
	

	/** 
     * 手机号验证 
     *  
     * @param  str 
     * @return 验证通过返回true 
     */  
    public static boolean isMobile(String str) {   
        Pattern p = null;  
        Matcher m = null;  
        boolean b = false;   
        p = Pattern.compile("[0-9]*"); 
        m = p.matcher(str);  
        b = m.matches();   
        return b;  
    }

    /**
     * getDictionaryList:( 系统类-app字典列表接口) - serviceImpl
     * 
     * @author 作者(ny)
     * @param version  app版本号
     * @param terminalCode  终端编码
     * @return 
     */
	@Override
	public GetDictionaryListResDto getDictionaryList(
			GetDictionaryListReqDto reqDto) {
		GetDictionaryListResDto resDto = new GetDictionaryListResDto();
		List<DictionaryListRes> rqBusNumList = new ArrayList<DictionaryListRes>();
		try{
			if(StringUtils.isBlank(reqDto.getBusNumType())){
				resDto.setResult(ResultEnum.FAILURE.getNo());
				resDto.setErrorMsg("业务类型不能为空");
				resDto.setErrorCode("0000");
				return resDto;
			}
			Long projectId = reqDto.getProjectId();
			if(projectId == null && StringUtils.isNotBlank(reqDto.getProjectCode())){
				ProjectDto entity = new ProjectDto();
				entity.setProjectCode(reqDto.getProjectCode());
				Project project = projectService.selectByDto(entity);
				if(project != null){
					projectId = project.getId();
				}
			}
			BaseCodeTypeDto baseCodeTypeDto = new BaseCodeTypeDto();
			baseCodeTypeDto.setMerchantId(reqDto.getMerchantId());
			baseCodeTypeDto.setCodeType(reqDto.getBusNum());
			baseCodeTypeDto.setProjectId(projectId);
			//baseCodeTypeDto.setTypeName(BaseCodeTypeEnum.getByNo(reqDto.getBusNumType()).getDes());
			//获取业务参数类型
			String type = reqDto.getBusNumType();
			//当传入的业务参数是数字时，转换为英文标识
			if(StringUtils.isNumeric(type)){
				type = BaseCodeTypeConvertEnum.getByNo(reqDto.getBusNumType()).getDes();
			}
			baseCodeTypeDto.setTypeValue(type);
			BaseCodeType baseCodeType = baseCodeTypeService.selectByDto(baseCodeTypeDto);
			if(baseCodeType != null){
				BaseCodeValueDto baseCodeValueDto = new BaseCodeValueDto();
				baseCodeValueDto.setTypeId(baseCodeType.getId());
				baseCodeValueDto.setMerchantId(reqDto.getMerchantId());
				baseCodeValueDto.setProjectId(reqDto.getProjectId());
				//只获取电转访
				if("1".equals(reqDto.getGetCallToVisit())) {
					baseCodeValueDto.setCodeName("电转访");
				}
				baseCodeValueDto.setOrders(" t.sort+0 asc ");
				List<BaseCodeValue> baseCodeValueList = baseCodeValueService.selectListByDto(baseCodeValueDto);
				if(baseCodeValueList != null && baseCodeValueList.size() > 0){
					for(BaseCodeValue baseCodeValue : baseCodeValueList){
						DictionaryListRes dictionaryListRes = new DictionaryListRes();
						dictionaryListRes.setDictionaryId(String.valueOf(baseCodeValue.getId()));
						dictionaryListRes.setDictionaryName(baseCodeValue.getCodeName());
						rqBusNumList.add(dictionaryListRes);
					}
					resDto.setRqBusNumList(rqBusNumList);
				}else{
					resDto.setRqBusNumList(null);
				}
			}else{
				resDto.setRqBusNumList(null);
			}
		}catch(Exception e){
			e.printStackTrace();
		}
		resDto.setResult(ResultEnum.SUCCESS.getNo());
		return resDto;
	}
	
	/**
     * getDictionaryListByProjectID:( 系统类-app字典列表接口) - serviceImpl
     * @author 作者(jzliu)
     * @param version  app版本号
     * @param terminalCode  终端编码
     * @return 
     */
	@Override
	public GetDictionaryListResDto getDictionaryListByProjectId(
			GetDictionaryListReqDto reqDto) {
		GetDictionaryListResDto resDto = new GetDictionaryListResDto();
		Map<String, DictionaryListRes[]> resMap = new HashMap<String, DictionaryListRes[]>();
		try{
			//获取当前商户和项目下的所有业务类型
			BaseCodeTypeDto baseCodeTypeDto = new BaseCodeTypeDto();
			baseCodeTypeDto.setMerchantId(reqDto.getMerchantId());
			baseCodeTypeDto.setCodeType(reqDto.getBusNum());
			baseCodeTypeDto.setProjectId(reqDto.getProjectId());
			baseCodeTypeDto.setOrders(" t.sort+0 asc ");
			List<BaseCodeType> typeList = baseCodeTypeService.selectListByDto(baseCodeTypeDto);
			if(typeList == null || typeList.size() == 0){
				resDto.setResult(ResultEnum.FAILURE.getNo());
				resDto.setErrorMsg("未查询到数据");
				return resDto;
			}
			for(BaseCodeType baseCodeType : typeList){
				//根据业务类型查询对应业务描述
				BaseCodeValueDto baseCodeValueDto = new BaseCodeValueDto();
				baseCodeValueDto.setTypeId(baseCodeType.getId());
				baseCodeValueDto.setMerchantId(reqDto.getMerchantId());
				baseCodeValueDto.setProjectId(reqDto.getProjectId());
				//只获取电转访
				if("1".equals(reqDto.getGetCallToVisit())) {
					baseCodeValueDto.setCodeName("电转访");
				}
				baseCodeValueDto.setOrders(" t.sort+0 asc ");
				List<BaseCodeValue> baseCodeValueList = baseCodeValueService.selectListByDto(baseCodeValueDto);
				if(baseCodeValueList == null || baseCodeValueList.size() == 0){
					resMap.put(baseCodeType.getTypeValue(), null);
				}else{
					DictionaryListRes[] strs = new DictionaryListRes[baseCodeValueList.size()];
					for(int i = 0; i < baseCodeValueList.size(); i++){
						BaseCodeValue baseCodeValue = (BaseCodeValue)baseCodeValueList.get(i);
						DictionaryListRes dictionaryListRes = new DictionaryListRes();
						dictionaryListRes.setDictionaryId(String.valueOf(baseCodeValue.getId()));
						dictionaryListRes.setDictionaryName(baseCodeValue.getCodeName());
						strs[i] = dictionaryListRes;
					}
					resMap.put(baseCodeType.getTypeValue(), strs); 
				}
			}
			resDto.setTypeMap(resMap);
		}catch(Exception e){
			e.printStackTrace();
		}
		resDto.setResult(ResultEnum.SUCCESS.getNo());
		return resDto;
	}

	   /**
	    * getNoticeCategoryList:( 系统类-app查询公告类别列表接口) - serviceImpl
	    * 
	    * @author 作者(ny)
	    * @param version  app版本号
	    * @param merchantId  商家Id
	    * @param logoutName  用户名
	    * @param token 会话token
	    * @param projectCode 项目code
	    * @param terminalCode  终端编码
	    * @return 
	    */
	@Override
	public GetNoticeCategoryListResDto getNoticeCategoryList(
			GetNoticeCategoryListReqDto reqDto) {
		GetNoticeCategoryListResDto resDto = new GetNoticeCategoryListResDto();
		CustomerCountDto customerCountDto = new CustomerCountDto();
		customerCountDto.setMerchantId(String.valueOf(reqDto.getMerchantId()));//商家Id
		customerCountDto.setProjectCode(reqDto.getProjectCode());//项目Code
		customerCountDto.setNoticeType(DictionaryTypeEnum.NOTICE.getNo());//消息类型：公告
		//查询所有公告分类列表
		List<NoticeListDto> noticeListDto_cateGory = noticeMapper.selectNoticeCategoryList(customerCountDto);
		List<NoticeList> noticeList_category = new ArrayList<NoticeList>();
		if(noticeListDto_cateGory.size() > 0){
			for(int i=0;i<noticeListDto_cateGory.size();i++){
				NoticeList noticeList_categoryEntity = new NoticeList();
				noticeList_categoryEntity.setNoticeCategoryId(noticeListDto_cateGory.get(i).getNoticeCategoryId());//公告Id
				noticeList_categoryEntity.setNoticeCategory(noticeListDto_cateGory.get(i).getNoticeCategory());//公告类别
				noticeList_category.add(noticeList_categoryEntity);
			}
			resDto.setNoticeCategoryList(noticeList_category);
		}else{
			resDto.setNoticeCategoryList(null);
		}
		resDto.setResult(ResultEnum.SUCCESS.getNo());
		return resDto;
	}

	   /**
	    * getVersion:( 版本升级-app查询新版本接口) - serviceImpl
	    * 
	    * @author 作者(ny)
	    * @param version  app版本号
	    * @param terminalCode  终端编码
	    * @return 
	    */
	@Override
	public GetVersionResDto getVersion(GetVersionReqDto reqDto) {
		GetVersionResDto resDto = new GetVersionResDto();
		try{
			//1、查询出最新版本
			VersionDto versionDto = new VersionDto();
			versionDto.setVersionType(reqDto.getVersionType());
			versionDto.setIsValid("1"); //有效
			Version version = versionMapper.queryVersion(versionDto);
			if(version != null){
				//2、与入参版本比较,是否为最新版本
				if(Integer.parseInt(reqDto.getVersion()) >= Integer.parseInt(version.getVersion())){
					resDto.setVersionDes("您已是最新版本,无需更新!");
				}else{
					resDto.setResult(ResultEnum.SUCCESS.getNo());
					resDto.setVersionId(String.valueOf(version.getId()));
					resDto.setVersionNum(version.getVersion());
					resDto.setVersionName(version.getRemark());//版本名称
					resDto.setVersionType(version.getVersionType());
					resDto.setVersionDes(version.getVersionDes());
					resDto.setVersionStatus(version.getVersionStatus());
					resDto.setVersionUrlAddress(version.getVersionUrlAddress());
				}
			}else{
				resDto.setVersionDes("暂无版本更新!");
			}
		}catch(Exception e){
			e.printStackTrace();
			resDto.setErrorCode("0000");
			resDto.setErrorMsg("查询新版本失败!");
			resDto.setResult(ResultEnum.FAILURE.getNo());
		}
		resDto.setResult(ResultEnum.SUCCESS.getNo());
		return resDto;
	}

	   /**
	    * downloadNewVersion:( 版本升级-app下载新版本接口) - serviceImpl
	    * 
	    * @author 作者(ny)
	    * @param version  app版本号
	    * @param terminalCode  终端编码
	    * @return 
	    */
	@Override
	public DownloadNewVersionResDto downloadNewVersion(DownloadNewVersionReqDto reqDto) {
		DownloadNewVersionResDto resDto = new DownloadNewVersionResDto();
		try{
			VersionDto versionDto = new VersionDto();
			versionDto.setId(Long.valueOf(reqDto.getVersionId()));
			versionDto.setIsValid("0"); //有效
			Version version = versionService.selectByDto(versionDto);
			if(version != null){
				resDto.setResult(ResultEnum.SUCCESS.getNo());
				resDto.setVersion(version.getVersion());
				resDto.setVersionUrlAddress(version.getVersionUrlAddress());
			}else{
				resDto.setResult(ResultEnum.SUCCESS.getNo());
				resDto.setErrorMsg("无新版本可下载!");
			}
		}catch(Exception e){
			e.printStackTrace();
			resDto.setErrorCode("0000");
			resDto.setErrorMsg("下载新版本失败!");
			resDto.setResult(ResultEnum.FAILURE.getNo());
		}
		resDto.setResult(ResultEnum.SUCCESS.getNo());
		return resDto;
	}

	 /**
	    * addProblemFeedback:( 版本升级-app新增问题反馈接口) - serviceImpl
	    * 
	    * @author 作者(ny)
	    * @param version  app版本号
	    * @param terminalCode  终端编码
	    * @return 
	    */
	@Override
	public AddProblemFeedbackResDto addProblemFeedback(
			AddProblemFeedbackReqDto reqDto) {
		AddProblemFeedbackResDto resDto = new AddProblemFeedbackResDto();
		try{
			//问题反馈文本记录
			ProblemFeedback problemFeedback = null;
			if(reqDto.getProblemContent() != null && !"".equals(reqDto.getProblemContent())){
				ProblemFeedbackDto problemFeedbackDto = new ProblemFeedbackDto();
				problemFeedbackDto.setProblemContent(reqDto.getProblemContent());
				User user = userService.selectById(Long.valueOf(reqDto.getUserId()));
				problemFeedbackDto.setUserCode(user.getUserCode());
				problemFeedbackDto.setProjectCode(reqDto.getProjectCode());
				problemFeedbackDto.setMerchantId(reqDto.getMerchantId());
				problemFeedbackDto.setDelFlag(DelFlagEnum.UNDEL.getNo());
				problemFeedbackDto.setCreateUserId(Long.valueOf(reqDto.getUserId()));
				problemFeedback = problemFeedbackService.create(problemFeedbackDto);
			}
			//问题反馈图片列表记录
			List<ProblemImageListRes> problemImageList = reqDto.getProblemImageList();
			if(problemImageList != null){
				for(ProblemImageListRes problemImageListRes : problemImageList){
					String imgName = SequencesGenerator.getUUID("IMG")+problemImageListRes.getProblemImageType();
					String result=FileUploadPorxyUtil.appPost(fileUploadUrl,problemImageListRes.getProblemImage(),imgName);
					JSONObject resultJson=JSON.parseObject(result);
					String postResult=resultJson.getString("result");
					if(!"1".equals(postResult)){
						resDto.setResult(ResultEnum.FAILURE.getNo());
						resDto.setErrorCode("00000");
						resDto.setErrorMsg("问题反馈图片上传失败");
						return resDto;
					}
					String postUrl=resultJson.getString("url");
					ImageDto imageDto = new ImageDto();
					imageDto.setObjectId(problemFeedback.getId());
					imageDto.setLargeUrl(postUrl);
					imageDto.setNormalUrl(postUrl);
					imageDto.setSmallUrl(postUrl);
					imageDto.setImgType(ImgTypeEnum.PROBLEMFEEDBACK.getNo());
					imageDto.setMerchantId(problemFeedback.getMerchantId());
					imageDto.setUserCode(problemFeedback.getUserCode());
					imageDto.setAccessCode(problemFeedback.getProjectCode());
					imageDto.setRemark("问题反馈");
					imageDto.setCreateUserId(problemFeedback.getCreateUserId());
					imageDto.setDelFlag(DelFlagEnum.UNDEL.getNo());
					imageService.create(imageDto);
				}
			}
		}catch(Exception e){
			e.printStackTrace();
			resDto.setErrorCode("0000");
			resDto.setErrorMsg("新增问题反馈失败!");
			resDto.setResult(ResultEnum.FAILURE.getNo());
		}
		resDto.setResult(ResultEnum.SUCCESS.getNo());
		return resDto;
	}

	 /**
	    * getCalculatePrice:( 房源-app算价接口) - serviceImpl
	    * 
	    * @author 作者(ny)
	    * @param version  app版本号
	    * @param terminalCode  终端编码
	    * @return 
	    */
	@Override
	public GetCalculatePriceResDto getCalculatePrice(
			GetCalculatePriceReqDto reqDto) {
		GetCalculatePriceResDto resDto = new GetCalculatePriceResDto();
		DecimalFormat df = new DecimalFormat("#.##");
		try{
			/*
			 * 贷款总额
			 * 贷款类型：1、组合贷款；2、公积金贷款；3、商业贷款
			 */
			Double monthlyRate = 0.0;
			Double monthlyRate_2 = 0.0;
			Double loanTotal = 0.0;
			Double loanTotal_2 = 0.0;
			Double monthlyRepayment_2 = 0.0;
			Double repaymentTotal_2 = 0.0;
			Double paymentInterest_2 = 0.0;
			Double paymentInterest2_2 = 0.0;
			Double repaymentTotal2_2 = 0.0;
			Double loanLife_2 = 0.0;
			Double firstMonthRepayment_2 = 0.0;
			Double mouthAmount_2 = 0.0;
			Double monthlyDecline_2 = 0.0;
			if("1".equals(reqDto.getLoanType())){
				loanTotal = Double.valueOf(reqDto.getFundLoan());
				loanTotal_2 = Double.valueOf(reqDto.getBusinessLoan());
				//月利率=年利率÷12
				monthlyRate	= (Double.valueOf(reqDto.getFundLoanRate())/100)/12;
				monthlyRate_2 = (Double.valueOf(reqDto.getBusinessLoanRate())/100)/12;
				/**
				 * 等额本息
				 */
				//每月还款=〔贷款金额×月利率×（1＋月利率）＾还款月数〕÷〔（1＋月利率）＾还款月数－1〕
				monthlyRepayment_2 = (loanTotal_2*monthlyRate_2*Math.pow((1+monthlyRate_2),Double.valueOf(reqDto.getLoanLife())))/(Math.pow((1+monthlyRate_2),Double.valueOf(reqDto.getLoanLife()))-1);
				//还款总额=每月还款*贷款月数
				repaymentTotal_2 = monthlyRepayment_2*Double.valueOf(reqDto.getLoanLife());
				//支付利息=还款总额-贷款总额
				paymentInterest_2 = repaymentTotal_2-loanTotal_2;
				/**
				 * 等额本金
				 */
				//总利息=〔(总贷款额÷还款月数+总贷款额×月利率)+总贷款额÷还款月数×(1+月利率)〕÷2×还款月数-总贷款额
				paymentInterest2_2 = ((loanTotal_2/Double.valueOf(reqDto.getLoanLife())+loanTotal_2*monthlyRate_2)+loanTotal_2/Double.valueOf(reqDto.getLoanLife())*(1+monthlyRate_2))/2*Double.valueOf(reqDto.getLoanLife()) -loanTotal_2; 
				//还款总额 = 总利息 + 贷款总额
				repaymentTotal2_2 = paymentInterest2_2+loanTotal_2;
				// 首月还款  = （贷款总额÷ 贷款月数）+（贷款总额- 0）× 每月利率
				loanLife_2 = Double.valueOf(reqDto.getLoanLife());
				firstMonthRepayment_2 = (loanTotal_2/loanLife_2)+(loanTotal_2-0)*monthlyRate_2;
				/**
				 * 1、每月应还本金=贷款本金÷还款月数
				 * 2、每月月供递减额=每月应还本金×月利率=贷款本金÷还款月数×月利率
				 */
				mouthAmount_2 = loanTotal_2/Double.valueOf(reqDto.getLoanLife());
				monthlyDecline_2 = mouthAmount_2*monthlyRate_2;
			}else if("2".equals(reqDto.getLoanType())){
				loanTotal = Double.valueOf(reqDto.getFundLoan());
				monthlyRate	= (Double.valueOf(reqDto.getFundLoanRate())/100)/12;
			}else if("3".equals(reqDto.getLoanType())){
				loanTotal = Double.valueOf(reqDto.getBusinessLoan());
				monthlyRate	= (Double.valueOf(reqDto.getBusinessLoanRate())/100)/12;
			}
			//贷款月数=用户选择
			resDto.setLoanMonth(reqDto.getLoanLife());
			resDto.setLoanMonth2(reqDto.getLoanLife());
			//每月还款=〔贷款金额×月利率×（1＋月利率）＾还款月数〕÷〔（1＋月利率）＾还款月数－1〕
			Double monthlyRepayment = (loanTotal*monthlyRate*Math.pow((1+monthlyRate),Double.valueOf(reqDto.getLoanLife())))/(Math.pow((1+monthlyRate),Double.valueOf(reqDto.getLoanLife()))-1);
			//还款总额=每月还款*贷款月数
			Double repaymentTotal = monthlyRepayment*Double.valueOf(reqDto.getLoanLife());
			//支付利息=还款总额-贷款总额
			Double paymentInterest = repaymentTotal-loanTotal;
			
			/**
			 * 返回字段【等额本息还款】
			 */
			if("1".equals(reqDto.getLoanType())){
				resDto.setLoanTotal(df.format((loanTotal+loanTotal_2)/10000));//贷款总额
				resDto.setRepaymentTotal(df.format((repaymentTotal+repaymentTotal_2)/10000));//还款总额
				resDto.setPaymentInterest(df.format((paymentInterest+paymentInterest_2)/10000));//支付利息
				resDto.setLoanMonth(reqDto.getLoanLife());//贷款月数
				resDto.setMonthlyRepayment(df.format(monthlyRepayment+monthlyRepayment_2));//每月还款
			}else{
				resDto.setLoanTotal(df.format(loanTotal/10000));//贷款总额
				resDto.setRepaymentTotal(df.format(repaymentTotal/10000));//还款总额
				resDto.setPaymentInterest(df.format(paymentInterest/10000));//支付利息
				resDto.setLoanMonth(reqDto.getLoanLife());//贷款月数
				resDto.setMonthlyRepayment(df.format(monthlyRepayment));//每月还款
			}
			/**
			 * 返回字段【等额本金还款】
			 */
			//总利息=〔(总贷款额÷还款月数+总贷款额×月利率)+总贷款额÷还款月数×(1+月利率)〕÷2×还款月数-总贷款额
			Double paymentInterest2 = ((loanTotal/Double.valueOf(reqDto.getLoanLife())+loanTotal*monthlyRate)+loanTotal/Double.valueOf(reqDto.getLoanLife())*(1+monthlyRate))/2*Double.valueOf(reqDto.getLoanLife()) -loanTotal; 
			//还款总额 = 总利息 + 贷款总额
			Double repaymentTotal2 = paymentInterest2+loanTotal;
			// 首月还款  = （贷款总额÷ 贷款月数）+（贷款总额- 0）× 每月利率
			Double loanLife = Double.valueOf(reqDto.getLoanLife());
			Double firstMonthRepayment = (loanTotal/loanLife)+(loanTotal-0)*monthlyRate;
			/**
			 * 1、每月应还本金=贷款本金÷还款月数
			 * 2、每月月供递减额=每月应还本金×月利率=贷款本金÷还款月数×月利率
			 */
			Double mouthAmount = loanTotal/Double.valueOf(reqDto.getLoanLife());
			Double monthlyDecline = mouthAmount*monthlyRate;
			if("1".equals(reqDto.getLoanType())){
				resDto.setLoanTotal2(df.format((loanTotal+loanTotal_2)/10000));//贷款总额
				resDto.setPaymentInterest2(df.format((paymentInterest2+paymentInterest2_2)/10000));//支付利息
				resDto.setRepaymentTotal2(df.format((repaymentTotal2+repaymentTotal2_2)/10000));//还款总额
				resDto.setLoanMonth2(reqDto.getLoanLife());//贷款月数
				resDto.setFirstMonthRepayment(df.format(firstMonthRepayment+firstMonthRepayment_2));//首月还款
				resDto.setMonthlyDecline(df.format(monthlyDecline+monthlyDecline_2));//每月递减
			}else{
				resDto.setLoanTotal2(df.format(loanTotal/10000));//贷款总额
				resDto.setPaymentInterest2(df.format(paymentInterest2/10000));//支付利息
				resDto.setRepaymentTotal2(df.format(repaymentTotal2/10000));//还款总额
				resDto.setLoanMonth2(reqDto.getLoanLife());//贷款月数
				resDto.setFirstMonthRepayment(df.format(firstMonthRepayment));//首月还款
				resDto.setMonthlyDecline(df.format(monthlyDecline));//每月递减
			}
			
			/**
			 * 新增算价记录
			 */
			User user = null;
			ProjectRoom proRoom = projectRoomService.selectById(Long.valueOf(reqDto.getRoomId()));
			if(proRoom != null){
				PriceRecordDto priceRecordDto = new PriceRecordDto();
				//物业类别
				if(proRoom.getPropertyType() != null && !"".equals(proRoom.getPropertyType())){
					priceRecordDto.setPropertyType(PropertyTypeEnum.getByNo(proRoom.getPropertyType()).getDes());
				}else{
					priceRecordDto.setPropertyType(null);
				}
				//户型名称
				if(proRoom.getHouseTypeId() != null && !"".equals(proRoom.getHouseTypeId())){
					ProjectHouseType projectHouseType = projectHouseTypeService.selectById(proRoom.getHouseTypeId());
					if(projectHouseType != null){
						if(projectHouseType.getHouseTypeName() != null && !"".equals(projectHouseType.getHouseTypeName())){
							priceRecordDto.setHouseName(projectHouseType.getHouseTypeName());
						}else{
							priceRecordDto.setHouseName(null);
						}
					}
				}else{
					priceRecordDto.setHouseName("车位");
				}
				priceRecordDto.setRoomId(Long.valueOf(reqDto.getRoomId()));//房间Id
				//用户Code
				user = userService.selectById(Long.valueOf(reqDto.getUserId()));
				priceRecordDto.setUserCode(user.getUserCode());
				//项目code
				priceRecordDto.setProjectCode(reqDto.getProjectCode());
				//商户Id
				priceRecordDto.setMerchantId(reqDto.getMerchantId());
				//创建人Id
				priceRecordDto.setCreateUserId(Long.valueOf(reqDto.getUserId()));
				//是否删除： 0 未删除
				priceRecordDto.setDelFlag(DelFlagEnum.UNDEL.getNo());
				priceRecordService.create(priceRecordDto);
			}
			
			/**
			 * 新增客户意向房源记录
			 */
			if(reqDto.getRoomId() != null && !"".equals(reqDto.getRoomId()) && reqDto.getCustomerId() != null && !"".equals(reqDto.getCustomerId())){
				BusinessRelationDto brDto = new BusinessRelationDto();
				brDto.setProjectId(reqDto.getProjectId());
				brDto.setProjectCode(reqDto.getProjectCode());
				brDto.setSingleId(Long.valueOf(reqDto.getCustomerId()));
				brDto.setRelationType(RelationTypeEnum.ROOM.getNo());
				brDto.setMoreId(Long.valueOf(reqDto.getRoomId()));
				brDto.setMerchantId(reqDto.getMerchantId());
				brDto.setUserCode(user.getUserCode());
				brDto.setAccessCode(reqDto.getProjectCode());
				brDto.setCreateUserId(Long.valueOf(reqDto.getUserId()));
				brDto.setDelFlag(DelFlagEnum.UNDEL.getNo());
				brDto.setRemark("客户关注房号");
				businessRelationService.create(brDto);
			}
			
		}catch(Exception e){
			e.printStackTrace();
			resDto.setErrorCode("0000");
			resDto.setErrorMsg("算价失败!");
			resDto.setResult(ResultEnum.FAILURE.getNo());
		}
		resDto.setResult(ResultEnum.SUCCESS.getNo());
		return resDto;
	}

	   /**
	    * remoteLogin:( 登录类-app异地登录接口) - serviceImpl
	    * 
	    * @author 作者(ny)
	    * @param version  app版本号
	    * @param merchantId  商家Id
	    * @param logoutName  用户名
	    * @param token 会话token
	    * @param terminalCode  终端编码
	    * @return 
	    */
	@Override
	public RemoteLoginResDto remoteLogin(RemoteLoginReqDto reqDto) {
		RemoteLoginResDto resDto = new RemoteLoginResDto();
		try{
			UserToken userToken = userTokenMapper.selectByUserId(Long.valueOf(reqDto.getUserId()));
			//登录状态：0 未登录；1、已登录；2、在其他设备登录；3、 会员登录状态异常；4、已锁定
			if(userToken != null){
				resDto.setStatus(userToken.getStatus());
			}else{
				resDto.setStatus(null);
			}
		}catch(Exception e){
			e.printStackTrace();
			resDto.setErrorCode("0000");
			resDto.setErrorMsg("异地登录业务查询失败!");
			resDto.setResult(ResultEnum.FAILURE.getNo());
		}
		resDto.setResult(ResultEnum.SUCCESS.getNo());
		return resDto;
	}
	
	private static byte[] getContentBytes(String content, String charset) {
        if (charset == null || "".equals(charset)) {
            return content.getBytes();
        }
        try {
            return content.getBytes(charset);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException("签名过程中出现错误,指定的编码集不对,您目前指定的编码集是:" + charset);
        }
    }
	
	public static String buildLogoUrl(String logoUrl, String logoType, String logoIndex){
		String appLogo = "";
		String urlPrefix = logoUrl.substring(0, logoUrl.lastIndexOf("."));
		String urlSuffix = logoUrl.substring(logoUrl.lastIndexOf("."));
		if("android".equals(logoType)){
			appLogo = urlPrefix + "_android" + urlSuffix;
		}else if("ios".equals(logoType)){
			if("1".equals(logoIndex)){
				appLogo = urlPrefix + "_ios_1x" + urlSuffix;
			}else if("2".equals(logoIndex)){
				appLogo = urlPrefix + "_ios_2x" + urlSuffix;
			}else if("3".equals(logoIndex)){
				appLogo = urlPrefix + "_ios_3x" + urlSuffix;
			}
		}
		return appLogo;
	}
}
